package com.vrv.im.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vrv.im.domain.ProjectBean;
import com.vrv.im.persistence.ProjectMapper;
import com.vrv.im.service.ProjectService;
import com.vrv.im.vo.BindProjectVo;
import com.vrv.im.vo.ProjectExtVo;

@Service
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    public ProjectMapper projectMapper;

    public List<ProjectBean> getAllProject() {
        List<ProjectBean> list = projectMapper.getAllProject();
        if (list != null && list.size() > 0)
            return projectMapper.getAllProject();
        else
            return null;
    }

    public ProjectExtVo getProjectExtVoByID(long userID, long projectID) {
        BindProjectVo searchCondition = new BindProjectVo();
        searchCondition.setUserID(userID);
        searchCondition.setProjectID(projectID);
        ProjectExtVo projectExtVo = projectMapper.getProjectExtVoByID(searchCondition);
        if (projectExtVo == null)
            return null;
        else
            return projectExtVo;
    }

    public List<ProjectBean> getProjectByListID(List<Long> list) {
        Map<String, List<Long>> map = new HashMap<String, List<Long>>();
        map.put("list", list);
        return projectMapper.getProjectByListID(map);
    }

    @Override
    public long addProject(ProjectBean pro) {
        projectMapper.addProject(pro);
        return pro.getProjectID();
    }

    @Override
    public ProjectBean getProjectByID(long projectID) {
        ProjectBean projectBean = projectMapper.getProjectByID(projectID);
        if (projectBean == null)
            return null;
        else
            return projectBean;
    }

}
